#include <thread_pool.hpp>

#include <functional>

#include "utils.h"

using namespace ccq;

class Player {
public:
    void open(std::function<void(bool)> callback) {
        if(callback) {
            // concurrent::async(callback, true);
            m_pool.post(callback, true);
        }
    }

    void close(std::function<void()> callback) {
        if(callback) {
            // concurrent::async(callback);
            m_pool.post(callback);
        }
    }

private:
    ccq::ThreadPool m_pool;
};

int main() {

    Player player;
    player.open([&](bool ok) {
        // utils::sleep(1);
        if(ok) {
            LOGI("Player Open success");
            player.close([]() {
                LOGI("Player Closed");
            });
        }
        else {
            LOGI("Player Open fail");
        }
    });
    utils::msleep(1);

    return 0;
}
